lib: Kill GPG agent when cleaning up tmp homedirs
authorDan Nicholson <nicholson@endlessm.com>
Thu, 10 Jan 2019 20:00:42 +0000 (14:00 -0600)
committerAtomic Bot <atomic-devel@projectatomic.io>
Wed, 19 Jun 2019 17:30:24 +0000 (17:30 +0000)
When a temporary directory is used for GPG operations, it's pretty clear
that the running agent will be useless after the directory is deleted.
Call the new `ot_gpgme_kill_agent ()` helper to kill gpg-agent rather
than leaving them it hanging around forever.

As it turns out, gnupg does have code to make gpg-agent automatically
exit when the homedir is removed (https://dev.gnupg.org/T2756), but
that's only available on gnupg 2.2 or newer. Possibly this code can be
dropped later when that's more widely deployed or users/distros have
been advised to backport the necessary changes.

Closes: #1799
Approved by: cgwalters

src/libostree/ostree-gpg-verifier.c
src/libostree/ostree-repo.c

index a279348eb395bcbe563a9842c6c3db52d492120c..95ed36eed6b8d5596efad92baa5193341f50b587 100644 (file)
@@ -87,6 +87,7 @@ verify_result_finalized_cb (gpointer data,
    *     finalize() method, but I didn't want this keyring hack
    *     bleeding into multiple classes. */
 
+  ot_gpgme_kill_agent (tmp_dir);
   (void) glnx_shutil_rm_rf_at (AT_FDCWD, tmp_dir, NULL, NULL);
 }
 
index da128c6a9e33ee97ee58242c6d4ac227be998acb..c6860408793f264e99954fb99ef897581e3e6ede 100644 (file)
@@ -2300,11 +2300,15 @@ out:
   if (remote != NULL)
     ostree_remote_unref (remote);
 
-  if (source_tmp_dir != NULL)
+  if (source_tmp_dir != NULL) {
+    ot_gpgme_kill_agent (source_tmp_dir);
     (void) glnx_shutil_rm_rf_at (AT_FDCWD, source_tmp_dir, NULL, NULL);
+  }
 
-  if (target_tmp_dir != NULL)
+  if (target_tmp_dir != NULL) {
+    ot_gpgme_kill_agent (target_tmp_dir);
     (void) glnx_shutil_rm_rf_at (AT_FDCWD, target_tmp_dir, NULL, NULL);
+  }
 
   g_prefix_error (error, "GPG: ");